package cn.tedu.coolshark.controller;


import cn.tedu.coolshark.mapper.ProductMapper;
import cn.tedu.coolshark.pojo.entity.Product;
import cn.tedu.coolshark.pojo.vo.ProductVO;
import cn.tedu.coolshark.pojo.vo.ProductVO2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Justin Parker
 * @author 2024/8/23 23:14
 * @version 1.0
 */
@Slf4j
@Api(tags = "商品模块管理")
@RestController
@RequestMapping("/v1/products")
public class ProductController {

    @Autowired
    private ProductMapper productMapper;

    @ApiOperation(value = "查询所有商品")
    @GetMapping("/select")
    public List<Product> select(){
        return productMapper.select();
    }
    @ApiOperation(value = "根据分类id查询商品")
    @GetMapping("/selectByCategoryId")
    public List<ProductVO> selectByCategoryId(Integer categoryId){
        return productMapper.selectByCategoryId(categoryId);
    }

    @ApiOperation(value = "根据id查询商品详情")
    @GetMapping("/selectById")
    public List<Product> selectById(Integer Id){
        return productMapper.selectById(Id);
    }

    @ApiOperation(value = "查询首页商品")
    @GetMapping("/selectHome")
    public List<ProductVO> selectHome(){
        return productMapper.selectHome();
    }

    @ApiOperation(value = "查询首页顶部商品")
    @GetMapping("/selectHomeTwo")
    public List<ProductVO2> selectHomeTwo(){
        return productMapper.selectHomeTwo();
    }
}
